import type { RouteRecordRaw } from 'vue-router'
/**
 * 路由meta对象参数说明
 * meta: {
 *      title:          菜单栏及 tagsView 栏、菜单搜索名称（国际化）
 *      hidden：        是否隐藏此路由
 *      icon：          菜单、tagsView 图标，阿里：加 `iconfont xxx`，fontawesome：加 `fa xxx`
 * }
 */

/**
 * 静态路由（默认路由）
 * 未登录，可以访问登录页面
 * 登录了，但是没权限，至少可以访问首页
 */
export const staticRoutes: RouteRecordRaw[] = [
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/login/index.vue'),
    meta: {
      hidden: true,
    },
  },

  {
    path: '/404',
    name: '404',
    component: () => import('@/views/error/404.vue'),
    meta: {
      hidden: true,
    },
  },

  {
    path: '/',
    component: () => import('@/layout/index.vue'),
    redirect: '/home',
    children: [
      {
        path: 'home',
        name: 'Home',
        component: () => import('@/views/home/index.vue'),
        meta: {
          title: '首页',
          // https://element-plus.gitee.io/zh-CN/component/icon.html#%E5%9B%BE%E6%A0%87%E9%9B%86%E5%90%88
          icon: 'ele-HomeFilled',
        },
      },
    ],
  },
  {
    path: '/chat',
    component: () => import('@/layout/index.vue'),
    redirect: '/chat/home',
    name: 'XChat',
    children: [
      {
        path: 'home',
        name: 'XChat',
        component: () => import('@/views/chat/index.vue'),
        meta: {
          title: '聊天室',
          // https://element-plus.gitee.io/zh-CN/component/icon.html#%E5%9B%BE%E6%A0%87%E9%9B%86%E5%90%88
          icon: 'ele-ChatRound',
        },
      },
    ],
  },
]

/**
 * 定义动态路由
 * 一上来不加载的，需要根据用户权限，来选择加载相应的路由
 */
export const allAsyncRoutes: Array<RouteRecordRaw> = [
  // 如果只有一个子路由，子路由的meta会作为父路由的meta使用

  {
    path: '/acl',
    component: () => import('@/layout/index.vue'),
    redirect: '/acl/user/list',
    name: 'Acl',
    meta: {
      title: '权限管理',
      icon: 'ele-Setting',
    },
    children: [
      {
        path: 'user/list',
        name: 'User',
        component: () => import('@/views/alc/user/index.vue'),
        meta: {
          title: '用户管理',
        },
      },
      {
        path: 'role/list',
        name: 'Role',
        component: () => import('@/views/alc/role/index.vue'),
        meta: {
          title: '角色管理',
        },
      },
      {
        path: 'role/auth',
        name: 'RoleAuth',
        component: () => import('@/views/alc/roleAuth/index.vue'),
        meta: {
          title: '角色管理',
          hidden: true,
        },
      },
      {
        path: 'permission/list',
        name: 'Permission',
        component: () => import('@/views/alc/permission/index.vue'),
        meta: {
          title: '菜单管理',
        },
      },
    ],
  },

  {
    path: '/product',
    component: () => import('@/layout/index.vue'),
    redirect: '/product/trademark/list',
    name: 'Product',
    meta: {
      title: '商品管理',
      icon: 'ele-ShoppingBag',
    },
    children: [
      {
        // 子路由地址不写 /，会自动补全父路由地址
        path: 'trademark/list',
        name: 'Trademark',
        component: () => import('@/views/product/trademark/index.vue'),
        meta: {
          title: '品牌管理',
        },
      },
      {
        // 子路由地址不写 /，会自动补全父路由地址
        path: 'attr/list',
        name: 'Attr',
        component: () => import('@/views/product/attr/index.vue'),
        meta: {
          title: '属性管理',
        },
      },
      {
        // 子路由地址不写 /，会自动补全父路由地址
        path: 'spu/list',
        name: 'Spu',
        component: () => import('@/views/product/spu/index.vue'),
        meta: {
          title: 'Spu管理',
        },
      },
    ],
  },
  // 如果只有多个子路由，父路由就必须定义meta
  {
    path: '/test',
    component: () => import('@/layout/index.vue'),
    redirect: '/test/1',
    name: 'XTest',
    meta: {
      title: '测试',
      icon: 'ele-Headset',
    },
    children: [
      {
        path: '1',
        name: 'XTest1',
        component: () => import('@/views/test/index.vue'),
        meta: {
          title: '测试1',
          // https://element-plus.gitee.io/zh-CN/component/icon.html#%E5%9B%BE%E6%A0%87%E9%9B%86%E5%90%88
          icon: 'ele-Headset',
        },
      },
      {
        path: '2',
        name: 'XTest2',
        component: () => import('@/views/test/index.vue'),
        meta: {
          title: '测试2',
          // https://element-plus.gitee.io/zh-CN/component/icon.html#%E5%9B%BE%E6%A0%87%E9%9B%86%E5%90%88
          icon: 'ele-Headset',
        },
      },
    ],
  },

]

/* 匹配任意的路由 必须最后注册 */
export const anyRoute = {
  path: '/:pathMatch(.*)',
  name: 'Any',
  redirect: '/404',
  meta: {
    hidden: true,
  },
}
